package com.chris.tinyurl.app.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HttpUtils {

    public static HttpUtils httpUtils = new HttpUtils();

    public static boolean verifyUrl(String url) {
        return httpUtils._verifyUrl(url);
    }

    /**
     * 验证是否是URL
     *
     * @param url
     * @return
     */
    public boolean _verifyUrl(String url) {

        // URL验证规则
        String regEx = "(http|https)://[^\\s]*";
        // 编译正则表达式
        Pattern pattern = Pattern.compile(regEx);
        // 忽略大小写的写法
        // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(url);
        // 字符串是否与正则表达式相匹配
        boolean rs = matcher.matches();
        return rs;

    }
}
